import { createRouter, createWebHistory } from "vue-router";
import VueCookie from "vue-cookies";
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/index",
      name: "Index",
      component: () => import("@/views"),
      children: [
        {
          path: "/user",
          name: "UserList,",
          component: () => import("@/views/sys/user/index.vue"),
        },
        {
          path: "/role",
          name: "RoleList,",
          component: () => import("@/views/sys/role/index.vue"),
        },
        {
          path: "/permission",
          name: "PermissionList,",
          component: () => import("@/views/sys/permission/index.vue"),
        },
        {
          path: "/category",
          name: "CategoryList,",
          component: () => import("@/views/mer/category/index.vue"),
        },
        {
          path: "/goods",
          name: "GoodsList,",
          component: () => import("@/views/mer/goods/index.vue"),
        },
        {
          path: "/marketing",
          name: "MarketList,",
          component: () => import("@/views/mer/marketing/index.vue"),
        },
        {
          path: "/logs",
          name: "LoginLogsList,",
          component: () => import("@/views/log/login/index.vue"),
        },
        {
          path: "/consumptionLogs",
          name: "ConsumptionLogsList,",
          component: () => import("@/views/log/consumption/index.vue"),
        },
        {
          path: "/notice",
          name: "NoticeList,",
          component: () => import("@/views/com/notice/index.vue"),
        },
        {
          path: "/complaints",
          name: "ComplaintsList,",
          component: () => import("@/views/com/complaints/index.vue"),
        },
        {
          path: "/visitor",
          name: "VisitorList,",
          component: () => import("@/views/com/visotor/index.vue"),
        },
        {
          path: "/car",
          name: "CarList,",
          component: () => import("@/views/com/car/index.vue"),
        },
        {
          path: "/repair",
          name: "RepairList,",
          component: () => import("@/views/com/repair/index.vue"),
        },
      ],
    },
    {
      path: "/",
      name: "LoginIndex",
      component: () => import("@/views/login/index.vue"),
    },
  ],
});
// router.beforeEach((to, from, next) => {
//   const token = VueCookie.get("token");
//   if (to.fullPath === "/" || token) {
//     next();
//     return;
//   }
//   next("/");
// });
export default router;
